#!/bin/bash
read -p "请输入要创建的用户名：" user
read -p "请输入要创建的数量：" count
for i in `seq 1 $count`
do
useradd $user
echo $user | passwd --stdin $user
echo "用户$user create successful"
echo "用户默认密码为：$user"
read -p "是否需要修改密码(yes/no) " choose
    case $choose in
    Y|YES|y|yes)
    read -p -s "请输入新密码：" passwd
    echo $passwd | passwd --stdin $user
    echo "用户$user密码修改成功";;
    N|NO|n|no)
    echo "即将退出" && sleep 2 && exit;;
    *)
    echo "输入错误" && exit;;
    esac
done